﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HeresyManager;

public partial class Controls_CharackterView : System.Web.UI.UserControl
{
    private Character character;

    public Character Character
    {
        get { return character; }
        set { character = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (character == null)
            return;
        CharacterName.Text = character.Name == null ? "" : ("Name " + character.Name);
        Career.Text = character.Career == null ? "" : "Career " + character.Career.Name;
        HomeWorld.Text = character.HomeWorld == null ? "" : "Homeworld " + character.HomeWorld.Name;
        Divination.Text = character.Divination == null ? "" : "Divinatation " + character.Divination.Name;
        Description.Text = character.Description == null ? "" : "Description " + character.Description;
        PlayerName.Text = character.PlayerName == null ? "" : "Player Name " + character.PlayerName;
        Rank.Text = character.Ranks.Count==0 ? "" : "Rank " + character.Ranks.Aggregate("", (s, a) => s + a.Name + ", ", a => a.Substring(0, a.Length - 2)); 
        Quirk.Text = character.Quirk == null ? "" : "Quirk " + character.Quirk;
        Ordo.Text = character.Factions == null ? "" : "Faction " + character.Factions;
        ExpSpend.Text = character.Factions == null ? "" : "Exp Spend " + character.SpendExp;
        ExpTotal.Text = character.Factions == null ? "" : "Exp Total " + character.TotalExp;
        WS.Text = character.WS == null ? "" : "WS " + character.WS;
        BS.Text = character.BS == null ? "" : "BS " + character.BS;
        S.Text = character.S == null ? "" : "S " + character.S;
        T.Text = character.T == null ? "" : "T " + character.T;
        Ag.Text = character.Ag== null ? "" : "Ag " + character.Ag;
        Int.Text = character.Int == null ? "" : "Int " + character.Int;
        Per.Text = character.Per== null ? "" : "Per " + character.Per;
        WP.Text = character.Wp== null ? "" : "WP " + character.Wp;
        Fel.Text = character.Fel== null ? "" : "Fel " + character.Fel;
        Skills.Text = character.Skills.Count==0? "" : "Skills " + character.Skills.Aggregate("", (s, a) => s + a.Item1.ToString() + ", ", a => a.Substring(0,a.Length-2));
        Traits.Text = character.Traits.Count ==0 ? "" : "Traits " + character.Traits.Aggregate("", (s, a) => s + a.Item1.ToString() + ", ", a => a.Substring(0, a.Length - 2));
        Talents.Text = character.Talents.Count ==0 ? "" : "Talents " + character.Talents.Aggregate("", (s, a) => s + a.Item1.ToString() + ", ", a => a.Substring(0, a.Length - 2));
        Wounds.Text = character.TotalWounds == null ? "" : "Wounds " + character.TotalWounds;
        Fate.Text = character.TotalFatepoints == null ? "" : "FateName " + character.TotalFatepoints;
        Insanity.Text = character.InsanityPoints == null ? "" : "Insanity " + character.InsanityPoints;
        Corruption.Text = character.CorruptionPoints == null ? "" : "Coruption " + character.CorruptionPoints;
    }
}